import request from '@/utils/request';
import { AxiosResponse } from 'axios';
import { inspectionplanPageQuery, inspectionplanForm, inspectionplanExecute } from '@/api/inspection/inspectionplanSetting/types';
type RES = Promise<AxiosResponse>;
/**
 * 查询巡计划
 * @param query
 * @returns {*}
 */

export const ApiGetInspectionplanSettingList = (query?: inspectionplanPageQuery): RES => {
  return request({
    url: '/inspection/plan/list',
    method: 'get',
    params: query
  });
};

/**
 * 新增巡检计划
 *
 * @param params 巡检计划表单参数（可选）
 * @returns 返回 RES 类型的结果
 */
export const ApiCreateInspectionplan = (params?: inspectionplanForm): RES => {
  return request({
    url: '/inspection/plan/addPlan',
    method: 'post',
    data: params
  });
};

/**
 * 修改巡检计划
 *
 * @param params 巡检计划表单参数（可选）
 * @returns 返回 RES 类型的结果
 */
export const ApiUpdateInspectionplan = (params?: inspectionplanForm): RES => {
  return request({
    url: '/inspection/plan/updatePlan',
    method: 'put',
    data: params
  });
};

/**
 * 删除巡检计划
 *
 * @param query 查询参数，可选
 * @returns 返回API请求结果
 */
export const ApiDeleteInspectionPlan = (ids?: string | number | any[]): RES => {
  return request({
    url: '/inspection/plan/delPlan/' + ids,
    method: 'delete'
  });
};

/**
 * 获取巡检路线详情
 *
 * @param query 查询参数，可选
 * @returns 返回API请求结果
 */
export const ApiGetInspectionPlanDetail = (id?: string | number): RES => {
  return request({
    url: '/inspection/plan/getXjPlanById/' + id,
    method: 'get'
  });
};

/**
 * 执行列表
 * @param query
 * @returns {*}
 */
export const ApiGetInspectionplanExecuteList = (id: string): RES => {
  return request({
    url: '/inspection/plan/implementlist/' + id,
    method: 'get'
  });
};
/**
 * 执行列表1
 * @param query
 * @returns {*}
 */

export const ApiGetplanSituationList = (query?: inspectionplanPageQuery): RES => {
  return request({
    url: '/system/planSituation/list',
    method: 'get',
    params: query
  });
};

/**
 * 指派巡检人
 * @param query
 * @returns {*}
 */

export const ApiAssignTask = (query?: any): RES => {
  return request({
    url: '/system/planSituation/assignTask',
    method: 'put',
    data: query
  });
};

/**
 * 任务重做
 * @param query
 * @returns {*}
 */

export const ApiReformPlan = (query?: any): RES => {
  return request({
    url: '/system/planSituation/reformPlan',
    method: 'put',
    data: query
  });
};
